package experiment12;

import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.HBox;
import javafx.scene.media.AudioClip;
import javafx.stage.Stage;

public class No_3 extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) {
        AudioClip audioClip=new AudioClip("2.mp3");
        HBox pane=new HBox();

        Button play=new Button("Play");
        Button loop=new Button("Loop");
        Button stop=new Button("Stop");
        play.setOnAction(event -> {
            audioClip.setCycleCount(1);
            audioClip.play();
        });
        loop.setOnAction(event -> {
            audioClip.setCycleCount(Timeline.INDEFINITE);
            audioClip.play();
        });
        stop.setOnAction(event -> {
            audioClip.stop();
        });
        pane.getChildren().addAll(play,loop,stop);

        primaryStage.setTitle("music player");
        primaryStage.setScene(new Scene(pane));
        primaryStage.show();
    }
}
